package org.sdfc.model.dfc.collection

import com.documentum.fc.client.IDfCollection
import com.documentum.fc.client.IDfTypedObject

import org.sdfc.model.dfc.DfcTypedObjectAdaptor

/** A single row of results from a collection.
 *  <p>
 *  Following constraints of collection traversal, a CollectionRow is invalidated
 *  once the collection moves to the next row.<br/>
 *  Subsequent uses are sanctioned with IllegalStateException.
 */
class CollectionRow (
  /** Underlying IDfCollection, defined as var in order to allow invalidate(). */
  private var coll : IDfCollection
)
extends DfcTypedObjectAdaptor {
  
  /** Returns the underlying IDfCollection or throws if this has been invalidated.  */
  protected def underlying : IDfTypedObject =
    if ( coll != null ) coll
    else throw new IllegalStateException("CollectionRow: invalidated") 
  
  
  /** Invalidates this for all use.<br/>
   *  This method is called when the collection moves to the next row.
   */
  protected[collection] def invalidate() { coll = null }
  
}
